From 0fe05d1e85dda5e2f13cf8c206ff32b9976779e5 Mon Sep 17 00:00:00 2001 From: =?utf8?q?=C3=98yvind=20Kol=C3=A5s?= Date: Sat, 19 Nov 2016 13:29:36 +0100 Subject: [PATCH] extension/fast-float: gain some speed by ignoring a couple high mantissa bits --- extensions/fast-float.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/extensions/fast-float.c b/extensions/fast-float.c index 392bcb5..bafdcc0 100644 --- a/extensions/fast-float.c +++ b/extensions/fast-float.c @@ -28,7 +28,7 @@ #define INLINE inline -#define LSHIFT 2 +#define LSHIFT 4 typedef float (* BablLookupFunction) (float value, void *data); @@ -92,7 +92,7 @@ babl_lookup (BablLookup *lookup, } { - uint32_t bm =u.i & 0b11000000000000000000000000000000; + uint32_t bm =u.i & 0b11110000000000000000000000000000; ua.i |= bm; ub.i |= bm; } @@ -158,6 +158,8 @@ babl_lookup_new (BablLookupFunction function, else if (precision <= 0.000649) shift = 15; else shift = 16; /* a bit better than 8bit sRGB quality */ + shift = 16; + /* Adjust slightly away from 0.0, saving many entries close to 0, this * causes lookups very close to zero to be passed directly to the * function instead. @@ -264,7 +266,6 @@ linear_to_gamma_2_2_lut (float val) return babl_lookup (fast_pow, val); } - static BablLookup *fast_rpow = NULL; static inline float core_rlookup (float val, void *userdata) @@ -600,8 +601,8 @@ init (void) float a; /* tweaking the precision - does impact speed.. */ - fast_pow = babl_lookup_new (core_lookup, NULL, 0.0, 1.0, 0.00033); - fast_rpow = babl_lookup_new (core_rlookup, NULL, 0.0, 1.0, 0.00033); + fast_pow = babl_lookup_new (core_lookup, NULL, 0.0, 1.0, 0.0033); + fast_rpow = babl_lookup_new (core_rlookup, NULL, 0.0, 1.0, 0.0033); for (f = 0.0; f < 1.0; f+= 0.0000001) { -- 2.30.2